package com.hu.video.service.impl;

import com.hu.video.entity.VideoVisibility;
import com.hu.video.mapper.VideoVisibilityMapper;
import com.hu.video.service.IVideoVisibilityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class VideoVisibilityServiceImpl implements IVideoVisibilityService {
    @Autowired
    private VideoVisibilityMapper mapper;

    @Override
    public VideoVisibility getByVideoId(Long videoId) {
        return mapper.selectByVideoId(videoId);
    }

    @Override
    public void setVisibility(VideoVisibility visibility) {
        if (mapper.selectByVideoId(visibility.getVideoId()) == null) {
            mapper.insert(visibility);
        } else {
            mapper.update(visibility);
        }
    }
} 